class Descrption extends PIXI.Container {
    constructor(uimanager) {
        super();
      
		this.uimanager = uimanager;

        const height = uimanager.realScreen.height;

		// 创建对话框
		const frame = new PIXI.smooth.SmoothGraphics();
		frame.beginFill(0x686028, 1);
		frame.lineStyle({ color: 0x181818, width: 1, alignment: 0 });
		frame.drawRoundedRect(0,0,260,height,25);
		frame.beginFill(0xE0E0C0, 1);
		frame.lineStyle({ color: 0x686028, width: 0, alignment: 0 });
		frame.drawRoundedRect(2,2,260-4,height-4,25);
		frame.endFill();
        
		this.addChild(frame);
        this.reset();
    }

    get visual() {
        return this._visual;
    }

    reset() {
        this._visual = false;
        this.x = this.uimanager.realScreen.width;
    }

    show(context) {

        if(this.richText)
            this.removeChild(this.richText);

		// 设置对话位置	
        const talkStyle = new PIXI.TextStyle({
            fontFamily: 'Arial',
            fontSize: 14,
            fontWeight: 'bold',
            fill: ['#201000'],
            wordWrap: true,
            breakWords:true,
            wordWrapWidth: 176,
            lineJoin: 'round',
            dropShadow: true,
            dropShadowColor: '#D0C890',
            dropShadowBlur: 1,
            dropShadowAngle: Math.PI / 6,
            dropShadowDistance: 3,
        });

		this.richText = new PIXI.Text(context, talkStyle);
		this.richText.x = 0;
		this.richText.y = 0;
		this.richText.resolution = 2;
		this.richText.position.set(10, 10);
	    this.addChild(this.richText);

        this.y = -this.parent.y + 25;

        this._visual = true;
        const target = this.uimanager.realScreen.width-this.width+25;
        createjs.Tween.get(this.position).to({x:target,y:this.y},(this.uimanager.realScreen.width - target) / 2);
    }

    close() {
        this._visual = false;
        createjs.Tween.get(this.position).to({x:this.uimanager.realScreen.width,y:this.y},(this.uimanager.realScreen.width - this.x) / 2);
    }
}